package com.zxy.salenet.web.mapper;

import com.zxy.salenet.web.pojo.SalenetGoods;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Value;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

 /**
   *  SalenetGoodsMapper。
     */
public interface SalenetGoodsMapper extends Mapper<SalenetGoods> {

    /**
     * 下架商品即删除商品
     *
     * @param goodsId
     * @return
     */
    @Update(value = "UPDATE salenet_goods SET goods_status = 3 WHERE goods_id = #{goodsId}")
    Integer updateGoodsStatusByGoodId(@Param("goodsId") Integer goodsId);

    /**
     * 重新上架删除的商品
     *
     * @param goodsId
     * @return
     */
    @Update(value = "UPDATE salenet_goods SET goods_status = 1 WHERE goods_id = #{goodsId}")
    Integer updateGoodsStatusByGoodIdUp(@Param("goodsId") Integer goodsId);

    /**
     * 获取特价商品   特价商品显示参数为4
     *
     * @return
     */
    @Select(value = "SELECT * FROM salenet_goods WHERE goods_status = 4")
    List<SalenetGoods> selectBargainListAll();

    /**
     * 获取今日上新产品
     *
     * @return
     */
    @Select(value = "SELECT  *  FROM  salenet_goods  WHERE  date(goods_putaway) = curdate() and goods_status = 1")
    List<SalenetGoods> selectNewGoods();

    /**
     * 获取项链系列产品
     *
     * @return
     */
    @Select(value = "SELECT * FROM salenet_goods WHERE goods_type = 99 limit 1,9")
    List<SalenetGoods> selectAGoodsList();

    /**
     * 获取戒指系列产品
     *
     * @return
     */
    @Select(value = "SELECT * FROM salenet_goods WHERE goods_type = 107 limit 1,9")
    List<SalenetGoods> selectBGoodsList();

    /**
     * 获取种类为玉石的产品
     *
     * @return
     */
    @Select(value = "SELECT * FROM salenet_goods WHERE goods_type = 88 limit 1,9")
    List<SalenetGoods> selectCGoodsList();

    /**
     * 获取口红类商品
     *
     * @return
     */
    @Select(value = "SELECT * FROM salenet_goods WHERE goods_type = 77 limit 1,9")
    List<SalenetGoods> selectDGoodsList();

    /**
     * 获取香水类商品
     *
     * @return
     */
    @Select(value = "SELECT * FROM salenet_goods WHERE goods_type = 44 limit 1,9")
    List<SalenetGoods> selectEGoodsList();

    /**
     * 根据姓名获取商品信息
     *
     * @param goodsName
     * @return
     */
    @Select(value = "SELECT * FROM salenet_goods WHERE goods_name like #{goodsName}")
    List<SalenetGoods> SelectAllGoodsByName(@Param("goodsName") String goodsName);

    /**
     * 根据商品分类获取商品
     *
     * @param goodsType
     * @return
     */
    @Select(value = "SELECT * FROM salenet_goods WHERE goods_type = #{goodsType}")
    List<SalenetGoods> SelectAllGoodsByType(@Param("goodsType") Integer goodsType);

    /**
     * 获取当前商品数量
     *
     * @param goodsId 当前商品的数量
     * @return
     */
    @Select(value = "select * from salenet_goods where goods_id = #{goodsId}")
    SalenetGoods queryGoodsCount(@Param("goodsId") Integer goodsId);

    /**
     * 验证是否是正品
     *
     * @param goodsId
     * @param code
     * @return
     */
    @Select(value = "select count(0) from salenet_goods where goods_id = #{goodsId} and goods_auth_code = #{code}")
    Integer selectTrueAndFalse(@Param("goodsId") Integer goodsId, @Param("code") Integer code);

    @Select(value = "select * from salenet_goods where goods_id = #{goodsId}")
    SalenetGoods selectGoodByGoodsId(@Param("goodsId") Integer goodsId);


    @Update(value = "UPDATE salenet_goods SET goods_count = #{curr} WHERE goods_id = #{goodsId}")
    Integer updateGoodsCounts(@Param("curr") Integer curr,@Param("goodsId") Integer goodsId);

    @Select(value = "select goods_img from salenet_goods where goods_id = #{goodsId}")
    String selectImgUrl(@Param("goodsId") Integer carGoodsId);
    /**
     * 完成
     */
}